-
Notifications
You must be signed in to change notification settings - Fork 949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: extend cri apis for get envs #2163
feature: extend cri apis for get envs #2163
Conversation
48a11a1
to
a3d4b03
Compare
96bd336
to
27df1ef
Compare
Codecov Report
@@ Coverage Diff @@
## master #2163 +/- ##
=========================================
- Coverage 64.44% 64.4% -0.05%
=========================================
Files 209 209
Lines 16723 16735 +12
=========================================
+ Hits 10777 10778 +1
- Misses 4622 4630 +8
- Partials 1324 1327 +3
|
@@ -774,6 +774,7 @@ func (c *CriManager) ContainerStatus(ctx context.Context, r *runtime.ContainerSt | |||
Volumes: parseVolumesFromPouch(container.Config.Volumes), | |||
Resources: parseResourcesFromPouch(resources, diskQuota), | |||
QuotaId: container.Config.QuotaID, | |||
Envs: parseEnvsFromPouch(container.Config.Env), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we should add Pouch
in the function naming. Please change a proper one. @starnop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@starnop Maybe we should rename the functions like parseEnvsFromPouch
, parseResourcesFromPouch
in another PR, they all do the same thing :)
@allencloud WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I will do that in the next pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still insist that we could finish in the pull request. How about convertEnvsForCRI
or convertContainerEnvForCRI
?
cri/v1alpha2/cri_utils.go
Outdated
for _, env := range pouchEnvs { | ||
runtimeEnv := &runtime.KeyValue{} | ||
if strings.Count(env, "=") == 1 { | ||
envItem := strings.Split(env, "=") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if env
is equal to a=b=c
? Do we need to cover this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allencloud Actually the envs here is returned from pouchd and they should have been validated when input to pouchd.
So maybe we don't need to check again here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in fact, the case a=b=c
will not be passed by pouchd.
Even if that happens, the upper level can also deal with it by key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you are using envItem[1]
to take b
and ignoring =c
, right? @starnop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a=b=c
is valid because b=c
is value.
# vagrant @ ubuntu-xenial in ~ [20:36:09]
$ A=1=2 echo ${A}
1=2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1087,6 +1087,22 @@ func parseVolumesFromPouch(containerVolumes map[string]interface{}) map[string]* | |||
return volumes | |||
} | |||
|
|||
// parseEnvsFromPouch parse Envs from []string to []*runtime.KeyValue | |||
func parseEnvsFromPouch(pouchEnvs []string) (criEnvs []*runtime.KeyValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are not parsing, you just did the translation thing.
cri/v1alpha2/cri_utils.go
Outdated
for _, env := range pouchEnvs { | ||
runtimeEnv := &runtime.KeyValue{} | ||
if strings.Count(env, "=") == 1 { | ||
envItem := strings.Split(env, "=") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a=b=c
is valid because b=c
is value.
# vagrant @ ubuntu-xenial in ~ [20:36:09]
$ A=1=2 echo ${A}
1=2
27df1ef
to
1d799d4
Compare
@fuweid Done. :) |
21296b8
to
27e88f2
Compare
Signed-off-by: Starnop <starnop@163.com>
27e88f2
to
59871c4
Compare
LGTM |
Signed-off-by: Starnop starnop@163.com
Ⅰ. Describe what this PR did
The CRI query container information interface adds the output of the environment variables, and returns the envs of the container in the
ContainerStatus
interfaceⅡ. Does this pull request fix one issue?
None.
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
Done.
Ⅳ. Describe how to verify it
crictl inspect
to view the container's environment variables.Ⅴ. Special notes for reviews
None.